import 'package:flutter/material.dart';
import 'package:flutter_boost/boost_navigator.dart';
import 'package:flutter_module/common/route/dialog_routes.dart';
import 'package:flutter_module/common/widget/video/video_view.dart';

/// Create by kyluzoi
/// Date: 2021-08-26
///
/// Description: 弹出层 播放器

class VideoPlayerDialog extends Dialog {
  final Map params;

  // final String videoUrl;
  // final String? videoCover;

  VideoPlayerDialog({Key? key, required this.params}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(left: 20, right: 20),
      child: Center(
        child: Stack(
          children: [
            VideoView(
              url: params["videoUrl"],
              cover: params["videoCover"],
            ),
            Positioned(
              left: 10,
              top: 10,
              child: InkWell(
                onTap: () {
                  BoostNavigator.instance.pop("");
                },
                child: Icon(
                  Icons.close,
                  color: Colors.white70,
                  size: 20,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }

  static show({required String videoUrl, String? videoCover}) {
    BoostNavigator.instance.push(DialogRouters.VIDEO_PLAYER_DIALOG,
        withContainer: false,
        arguments: {"videoUrl": videoUrl, "videoCover": videoCover});
  }
}
